﻿using B.S.GridManager.Api.Write.Application.Command.LogicGrid;
using B.S.GridManager.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManager.Api.Write.Controllers
{

    /// <summary>
    /// 逻辑网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogicController : ControllerBase
    {
        private readonly IMediator mediator;

        public LogicController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加逻辑网格的接口
        /// </summary>
        /// <param name="request">添加逻辑网格参数</param>
        /// <returns>通用的包装响应对象</returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateLogic(CreateLogicCommand request) { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新逻辑网格的接口
        /// </summary>
        /// <param name="request">更新逻辑网格参数</param>
        /// <returns>通用的包装响应对象</returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateLogic(UpdateLogicCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 删除逻辑网格的接口
        /// </summary>
        /// <param name="request">删除逻辑网格参数</param>
        /// <returns>通用的包装响应对象</returns>
        [HttpPost]
        public Task<ApiResult<int>> DelLogic(DelLogicCommand request)
        {
            return mediator.Send(request);
        }


    }
}
